strings = [input().strip() for _ in range(4)]
min_str = 'Z' * 114514
for i in range(4):
    for j in range(4):
        if j == i:
            continue
        for k in range(4):
            if k == i or k == j:
                continue
            l = 6 -i -j -k
            cur = strings[i] + strings[j] + strings[k] + strings[l]
            if cur < min_str:
                min_str = cur

print(min_str)
